//
//  displayGeometry.m
//  Reflect
//
//  Created by thrust on Fri Oct 14 2005.
//  Copyright (c) 2005 r. All rights reserved.
//

#import "displayMetrics.h"
#import "DisplayIDHelper.h"

@implementation displayMetrics

-(id)
initWithCGDirectDisplayID:(CGDirectDisplayID) directDisplayID {
	if ((self = [super init]) != nil) {
		_directDisplayID = directDisplayID;
	}
	return self;
}

-(id)
initWithCGDirectDisplayIDAsString:(NSString *) directDisplayIDAsString {
	if ((self = [super init]) != nil) {
		_directDisplayID = convertStringToDisplayID(directDisplayIDAsString);
	}
	return self;
}

-(id)
initWithCGDirectDisplayIDAsNumber:(NSNumber *) directDisplayIDAsNumber {
	if ((self = [super init]) != nil) {
		_directDisplayID = convertNumberToDisplayID(directDisplayIDAsNumber);
	}
	return self;
}

-(CGDirectDisplayID)
displayID {
	return _directDisplayID;
}

-(CGRect) bounds {
	return CGDisplayBounds(_directDisplayID);
}

// adjust by scaling factor, 5/64 is what the displays pref pane uses.
-(CGRect) placeholderBounds {
	CGRect bounds = CGDisplayBounds(_directDisplayID);
	float scale = 5.0f/64.0f;
	
	bounds.size.width *= scale;
	bounds.size.height *= scale;
	bounds.origin.x *= scale;
	bounds.origin.y *= scale;
	return bounds;
}

-(uint32_t)
unitNumber {
	return CGDisplayUnitNumber(_directDisplayID);
}

-(bool)
main {
	return CGDisplayIsMain(_directDisplayID);
}

-(bool)
accelerated {
	return CGDisplayUsesOpenGLAcceleration(_directDisplayID);
}

-(bool)
online {
	return CGDisplayIsOnline(_directDisplayID);
}

-(bool)
active {
	return CGDisplayIsActive(_directDisplayID);
}

@end
